package com.wonders.redisson;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO：配置连接Redisson
 * @Author: yyalin
 * @CreateDate: 2023/8/9 17:04
 * @Version: V1.0
 */
@Configuration
public class MyRedissonConfig {
    @Bean
    public RedissonClient getRedisson() {
        // 默认连接地址 127.0.0.1:6379
        // RedissonClient redisson = Redisson.create();
        //1.创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        //也可以使用config.useClusterServers()添加集群地址
        //2.根据config创建处RedissonClient实例
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
